package br.com.portalecbahia.customize;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import br.com.portalecbahia.R;
import br.com.portalecbahia.model.Setting;

public class SettingsListAdapter extends BaseAdapter {
    
	private Context context;

    private List<Setting> listSetting;
   
    public SettingsListAdapter (Context context, List<Setting> listSetting){
        this.context = context;
        this.listSetting = listSetting;
    }
    
	public int getCount() {
		// TODO Auto-generated method stub
		return  listSetting.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listSetting.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
        // Recupera o estado da posição atual
		Setting setting = listSetting.get(position);

		
        
        // na View
        LayoutInflater inflater = (LayoutInflater)
            context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.item_list_settings, null);
        

        
        // Title Item
        TextView textTitle = (TextView)view.findViewById(R.id.title);
        textTitle.setText(setting.getTitle());
        
        
        ImageView iconIMG = (ImageView)view.findViewById(R.id.image);
        iconIMG.setBackgroundResource(setting.getDrawable());
        
        ImageView imageArrow = (ImageView)view.findViewById(R.id.arrowIMG);
      
        	imageArrow.setVisibility(View.VISIBLE);	
        
        
    
        
        
        return view;
	}

}
